package com.dididoctor.patient.Bean;

import org.litepal.crud.DataSupport;

import java.io.Serializable;
import java.util.List;

public class ServiceLitapal extends DataSupport implements Serializable {

    private String serviceid;//服务项目ID
    private String name;//挂号服务项目名称
    private String memo;//挂号描述项目名称描述

    private boolean isChoice;

    public boolean isChoice() {
        return isChoice;
    }

    public void setChoice(boolean isChoice) {
        this.isChoice = isChoice;
    }

    public String getServiceid() {
        return serviceid;
    }

    public void setServiceid(String serviceid) {
        this.serviceid = serviceid;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setIsChoice(boolean isChoice) {
        this.isChoice = isChoice;
    }

    /**
     * 服务列表
     *
     * @return
     */
    public static List<ServiceLitapal> getAllServiceLitapal() {
        List<ServiceLitapal> findAll = DataSupport.findAll(ServiceLitapal.class);
        return findAll;

    }

    /**
     * 服务列表模糊查询
     *
     * @return
     */
    public static List<ServiceLitapal> getAllServiceLitapal(String name) {
        List<ServiceLitapal> find = DataSupport.where("hospital_name like ?", "%" + name + "%").find(ServiceLitapal.class);
        return find;

    }


    /**
     * 通过id遍历数据
     *
     * @param id
     * @return
     */
    public static ServiceLitapal getidServicelitapal(String id) {
        List<ServiceLitapal> all = DataSupport.where(" serviceid = ?", id).find(ServiceLitapal.class);
        if (all.size() > 0 && all != null) {
            return all.get(0);
        }
        return null;
    }

    /**
     * 通过服务ID 获取对应内容
     *
     * @param service
     * @return
     */
    public static String getServiceIdName(String service) {
        String name = "";
        if ("".equals(service) && service != null) {
            String[] ids = (service + ",").split(",");
            for (int x = 0; x < ids.length; x++) {
                ServiceLitapal serviceLitapal = ServiceLitapal.getidServicelitapal(ids[x]);
                if (serviceLitapal != null) {
                    name += serviceLitapal.getName() + ",";
                }

            }
        }
        return name;
    }

}
